package com.mck.service.impl;

import com.mck.entity.Classname;
import com.mck.entity.ScoreStats;
import com.mck.mapper.ClassnameMapper;
import com.mck.mapper.ScoreStatsMapper;
import com.mck.service.RedisTestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RedisTestServiceImpl implements RedisTestService {

    @Autowired
    private ClassnameMapper  classnameMapper;
    @Autowired
    private ScoreStatsMapper  scoreStatsMapper;

    @Override
    public List<Classname> getClassData() {
        return classnameMapper.getClassnameList();
    }

    @Override
    @Cacheable(value = "classname", key = "'all'")
    public List<Classname> getRedisClassData() {
        return classnameMapper.getClassnameList();
    }

    @Override
    @Cacheable(value = "scoreStats", key = "'all'")
    public List<ScoreStats> getRedisScoreStatsData() {
        ScoreStats scoreStats = new ScoreStats();
        scoreStats.setSubjectId(10);
        return scoreStatsMapper.getScoreStatsList(scoreStats);
    }

    @Override
    public List<ScoreStats> getScoreStatsData() {
        ScoreStats scoreStats = new ScoreStats();
        scoreStats.setSubjectId(10);
        return scoreStatsMapper.getScoreStatsList(scoreStats);
    }
}
